﻿{% extends "base.html" %}
{% block title %}PPD数据同步{% endblock %}
{% block head %}
{% endblock %}
{% block contentheader %}PPD数据同步{% endblock %}
{% block contentsmallheader %}监控每天同步拍拍贷数据的程序执行状况{% endblock %}
{% block content %}
    <div class="row">
        <div class="col-md-4">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title fa fa-tv"> PPD数据同步任务执行情况( 7 Days )</h3>
                    <div class="box-tools">
                        <button type="button" class="btn btn-box-tool" id="list_error">error
                        </button>
                        <button type="button" class="btn btn-box-tool" id="list_all">all
                        </button>
                        <button type="button" class="btn btn-box-tool " data-widget="collapse"><i
                                class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body no-padding" style="display: block;">
                    <ul class="nav nav-pills nav-stacked" id="task_list" style="overflow: auto;max-height: 700px">
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-md-8" id="table_name">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title fa fa-tv"></h3>
                    <div class="box-tools">
                        <button type="button" class="btn btn-box-tool " data-widget="collapse"><i
                                class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body no-padding" style="display: block;">
                    <ul class="nav nav-pills nav-stacked" id="table_error" style="overflow: auto;max-height: 700px">
                    </ul>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block script %}
    <script>
        function add_class() {
            $('#treeview4').addClass('active');
            $('#menu4').addClass('menu-open');
            $('#monitorppdsync').addClass('active');
        }
        $('#table_name').hide();
        $.ajax({
            url: "/monitor_ppddatasync_get_data", success: function (data) {
                for (var key in data.data) {
                    if (data.data[key].length == 0)
                        $("#task_list").append("<li class='t_ok' data-target=''><a><i class='fa fa-tasks'></i> " + key + "</a></li>");
                    else
                        $("#task_list").append("<li data-target='" + data.data[key] + "'><a><i class='fa fa-tasks'></i> " + key + "<span class='label label-danger pull-right'>[" + data.data[key].length + "] </span> </a></li>");
                }
                $('.t_ok').hide();
            }
        });
        $('#list_error').on('click', function () {
            $('.t_ok').hide();
        });
        $('#list_all').on('click', function () {
            $('.t_ok').show();
        });
        $('#task_list').on('click', 'li', function () {
            $('#table_error').empty();
            $('#table_name').hide();
            if ($(this).attr('data-target') != '') {
                $('#table_name h3').text($(this).text() + '同步失败的表：');
                var table = $(this).attr('data-target');
                var tables = table.split(',');
                for (var i = 0; i < tables.length; i++) {
                    $("#table_error").append("<li data-target=''><a><i class='fa fa-table'></i> " + tables[i] + "</a></li>");
                }
                $('#table_name').show();
            }
        });

    </script>
{% endblock %}